/*
 * q.h
 *
 *  Created on: 2016-10-29
 *      Author: m
 */

#ifndef SRC_INCLUDE_LIB_Q_H_
#define SRC_INCLUDE_LIB_Q_H_
#include "type.h"


typedef struct {
    char* write_pos;//写入位置
    char* read_pos;//开始解析的读取位置
    char* buf_base;
    u32 buf_len;
    u32 count; //Q中当前有多少个元素
    u32 ele_len; //每个元素的大小，字节单位
    u32 cap_cnt; //能够容纳元素个数上限
} Q;


void q_init(Q* q, char* buf, u32 buf_len, u32 ele_len);
int q_push(Q* q, void* ele);
int q_pop(Q* q, void* ele);

u32 q_size(Q* q);//return the element count in q
int q_front(Q* q, void* ele, u32 idx);
int q_back(Q* q, void* ele, u32 idx);
#endif /* SRC_INCLUDE_LIB_Q_H_ */
